const HtmlWebpackPlugin = require("html-webpack-plugin");
const overall = require("./public/mock/overall.json");
const area = require("./public/mock/area.json");
const news = require("./public/mock/news.json");

module.exports = {
  devServer: {
    before(app) {
      app.get("/api/overall", (req, res) => {
        res.json(overall);
      });
      app.get("/api/area", (req, res) => {
        res.json(area);
      });
      app.get("/api/news", (req, res) => {
        res.json(news);
      });
    },
    proxy: {
      "/nCoV": {
        target: "https://lab.isaaclin.cn",
        changeOrigin: true,
        secure: true,
        pathRewrite: {
          "^/nCoV": "/nCoV"
        }
      }
    }
  },
  configureWebpack: config => {
    config.plugins.forEach(val => {
      if (val instanceof HtmlWebpackPlugin) {
        val.options.title = "疫情监控";
      }
    });
  }
};
